package com.liuzhilong.infrastructure.basic.adapter;

import com.liuzhilong.infrastructure.basic.adapter.otherservice.SomeOtherService;
import lombok.Data;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 适配{@link SomeOtherService},转化为{@link MyService}的结构
 * @author longandai@163.com
 */
@Setter
@Accessors(chain = true)
public class SomeOtherServiceAdapter implements MyService {
    private SomeOtherService someOtherService;

    /**
     * 模拟适配
     * @return
     */
    @Override
    public String doSomeService() {
        //从someOtherService的someMethod1和someMethod2中聚合出结果
        return someOtherService.someMethod1()+" with "+someOtherService.someMethod2();
    }


    public static final SomeOtherServiceAdapter create(SomeOtherService someOtherService){
        return new SomeOtherServiceAdapter().setSomeOtherService(someOtherService);
    }
}
